﻿<?php
include_once('../../includes/metodos.php');
include_once('action.php');

checkUser();
include_once('../cabecalho.php');

if(!empty($_POST['cmd']) && $_POST['cmd']=='edit'){
	edit(anti_injection($_POST['id']));
}
connectSql();

$query = mysql_query("SELECT * FROM econ_usuarios WHERE id=".$_SESSION['id']);
$row = mysql_fetch_array($query);
$permissao = $row['permissao'];

$query = mysql_query("SELECT * FROM econ_colunista WHERE id=".anti_injection($_REQUEST['id']));
$row = mysql_fetch_array($query);
$user_id = $row['usuario_id'];
?>
<div id="conteudo_edit_col">
    <br>
    <div id="conteudo_editarcampos_col">
		<form action="edit.php" method="post">
		<label id="label_tit_edit_colunista">Titulo:</label>
		<input id="input_titulo_edit_col" type="text" name="titulo" value="<?php echo $row['titulo'];?>"/>
		<label id="label_assuntos_col_edit">Assuntos Relacionados:</label>
		<input id="iput_col_edit_rel" type="text" name="tags" value="<?php echo $row['tags'];?>"/><br>
		<?php 
			if($permissao==1){
				echo '<label>Colunista </label>';
				echo '<select name="colunista">';
				$query2 = mysql_query("SELECT * FROM econ_usuarios WHERE status=1 AND (permissao=2 OR id=71) ORDER BY nome ASC");
				while ($row2 = mysql_fetch_array($query2)) {
					if($user_id == $row2['id']){
						echo '<option selected="selected" value="'.$row2['id'].'">'.$row2['nome'].'</option>';
					}else{
						echo '<option value="'.$row2['id'].'">'.$row2['nome'].'</option>';
					}
				}
				echo '</select>';
			}
		?>
		<div style="width:74px;float:right;">
		<label id="labelestatus_col_edit">Status</label>
		<br>
		<?php 
			if($row['status']==1){
				echo '<input type="radio" name="status" value="1" checked="checked" /><label id="label_col_new_ativo">Ativo</label><br/>';
				echo '<input type="radio" name="status" value="2" /><label id="label_col_new">Inativo</label><br/>';
			}else{
				echo '<input type="radio" name="status" value="1" /><label id="label_col_new_ativo">Ativo</label><br/>';
				echo '<input type="radio" name="status" value="2" checked="checked" /><label id="label_col_new">Inativo</label><br/>';
			}
		
		?>
		</div>
		<br>
	 </div>	
	 <br><br><br>
	 <div style="width:696px;margin:0 auto;">
		<textarea rows="" cols="" name="conteudo"> <?php echo $row['conteudo'];?> </textarea><br/>
		<input type="hidden" name="cmd" value="edit">
		<input type="hidden" name="id" value="<?php echo anti_injection($_REQUEST['id']);?>">
		<input id="nova_noticia" type="submit" value="Editar"/>
	    </form>
	 </div>
</div>	    